import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public class Solution2478 {
    public int beautifulPartitions(String s, int k, int minLength) {
        int mod=1000000007;
        Set<Character> set=new HashSet<>(Arrays.asList('2','3','5','7'));
        int[][] f=new int[k+1][s.length()+1];
        int[][] g=new int[k+1][s.length()+1];
        Arrays.fill(g[0],set.contains(s.charAt(0))?1:0);
        for (int i=minLength-1;i<s.length();i++){
            for (int j=1;j<=k;j++){
                f[j][i+1]=(set.contains(s.charAt(i))?0:g[j-1][i-minLength+1]);
                g[j][i+1]=(g[j][i]+(i+1<s.length() && set.contains(s.charAt(i+1))?f[j][i+1]:0))%mod;
            }
        }
        return f[k][s.length()];
    }

    public static void main(String[] args) {
        System.out.println(new Solution2478().beautifulPartitions("23542185131",3,2));
    }
}
